		function brandNewOneFunc(urlpath,param){//前后端数据交互,ajax
			$.ajax({
				url:urlpath,
				datatype:"json",
				type:"post",
				data:param,
				success:function(data){
					 result=data;
					showStudyRoomInfo(data[0]);//自习室表格信息的分页显示
					pageNav();
				}
			})
		}
		
		var op="queryByPage";
		var array={"op":op};
		brandNewOneFunc("StudyRoomManageServlet",array);//自习室信息初始化

		function pageNav(){
			layui.use('laypage', function(){
				  var laypage = layui.laypage;
				  //执行一个laypage实例
				  laypage.render({
				    elem: 'pagediv' //注意，这里的 test1 是 ID，不用加 # 号
				    ,count: result[1].totalCount //数据总数，从服务端得到
				    ,curr:   result[1].page
				    ,limit:   result[1].pageSize
				    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
				  ,jump: function(obj, first){
					    page=obj.curr;
					    pageSize=obj.limit;
					    if(!first){
					      //do something
					       var array={"op":"queryByPage","page":obj.curr,"pageSize":obj.limit};
					       brandNewOneFunc("StudyRoomManageServlet",array);
					      }
				    }
				  });
				});
		}

			    $(function () {

			        let form = layui.form
			            ,laydate = layui.laydate,
			            laypage = layui.laypage,
			            layer = layui.layer,
			            table = layui.table;
			        
			        $('body').on("click",".btn-del",function () {
				         var pre = $(this);
				         layui.layer.confirm('确定要删除么？',{
				                btn:['确定','取消']
				        },function () {
				        	layui.layer.closeAll('dialog');
				        	var op="deleteStudyRoom";
							var Rno=$(pre).parent().parent().find("td").children().eq(0).val();
							console.log("Rno:"+Rno);
							var array={"Rno":Rno,"op":op,"page":page,"pageSize":pageSize};
							brandNewOneFunc("StudyRoomManageServlet",array);
				            //$(pre).parent().parent().remove();
				            
				        })
				    });
			        
			    });
	     //增加新电影
		function addStudyRoom(){
			var study_Room_No_add=document.getElementById("study_Room_No_add").value;
			var study_Room_Location_add=document.getElementById("study_Room_Location_add").value;
			var study_Room_Admin_add=document.getElementById("study_Room_Admin_add").value;
			var study_Room_Admin_add=document.getElementById("study_Room_Status_add").value;
			if(study_Room_No_add==""){alert("自习室编号不能为空");return;}
			else if(study_Room_Location_add==""){alert("自习室位置不能为空");return;}
			else if(study_Room_Admin_add==""){alert("自习室管理员不能为空");return;}
			else if(study_Room_Status_add==""){alert("自习室状态不能为空");return;}
			var flag=confirm("是否确认添加");
			if(flag)
				{
				    var array=$('#myModal_addStudyRoom').serialize();
					 var pageArray="&op=addStudyRoom&page="+page+"&pageSize="+pageSize+"";
					 var combinedArray=array+pageArray;
					 console.log("combinedArray:"+combinedArray);
					 brandNewOneFunc("StudyRoomManageServlet",combinedArray);
				}
			return;
		}
		
		//修改电影
		function editStudyRoom(){
			var flag=confirm("是否修改");
			if(flag)
				{
				 var array=$('#myModal').serialize();
				 var pageArray="&op=editStudyRoom&page="+page+"&pageSize="+pageSize+"";
				 var combinedArray=array+pageArray;
				 console.log("combinedArray:"+combinedArray);
				 brandNewOneFunc("StudyRoomManageServlet",combinedArray);
				}
		}
		//查询自习室
		function searchStudyRoom(){
				   var   keywords=document.getElementById("searchContent").value;
				    var array={"op":"queryByPage","page":page,"pageSize":pageSize,"keywords":keywords};
				    brandNewOneFunc("StudyRoomManageServlet",array);
		}
		
	
		






function showStudyRoomInfo(jsonstr){//显示表格数据
	console.log("调用showStudyRoomInfo");
	var data = jsonstr;
	document.getElementById("tbody1").innerHTML="";
	var HTML ="";
		if(data!=null)
		{
			for(var i=0;i<data.length;i++){
			 HTML += '<tr>\n' +
             '                            <td >\n' +
             '                                <input class="layui-input" name="roomNo"  readonly="readonly" value="'+data[i].Rno+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             ' 										<input class="layui-input" name="Rposition"  readonly="readonly" value="'+data[i].Rposition+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '                                <input type="text" name="Ano" class="layui-input" readonly="readonly" value="'+data[i].Ano+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '  								<input class="layui-input" name="roomStatus" readonly="readonly" value="'+data[i].Rstatus+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '                                <input type="text" name="seatNum" class="layui-input" readonly="readonly" value="'+data[i].Rseatnum+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '          <input type="text" name="freeSeatNum" class="layui-input" readonly="readonly" value="'+data[i].Rfreeseat+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '                                <input type="text"  name="StartTime" class="layui-input" placeholder="yyyy-MM-dd-ss"  readonly="readonly" value="'+data[i].Rstime+'">\n' +
             '                            </td>\n' +
             '                            <td>\n' +
             '                                <input type="text" name="EndTime" class="layui-input" placeholder="yyyy-MM-dd-ss"  readonly="readonly" value="'+data[i].Retime+'">\n' +
             '                            </td>\n' +
             '                            <td style="text-align: center" ><button type="button" class="layui-btn layui-btn-danger btn-del" " >删除</button>\n' +
             '                            <button type="button" class="layui-btn layui-btn-danger btn-edit" onclick="initialShadeLayer(this)" data-toggle="modal"  href="#myModal">修改</button></td>\n' +
             '                        </tr>';
			  }
			
			document.getElementById("tbody1").innerHTML=HTML;
       }
}


		function initialShadeLayer(this1)//初始化修改遮罩层
		{
			 var Rno=$(this1).parent().parent().find("td").children().eq(0).val();
			 var Rposition=$(this1).parent().parent().find("td").children().eq(1).val();
			 var Ano=$(this1).parent().parent().find("td").children().eq(2).val();
			 var Rstatus=$(this1).parent().parent().find("td").children().eq(3).val();
			 var Rseatnum=$(this1).parent().parent().find("td").children().eq(4).val();
			 var Rfreeseat=$(this1).parent().parent().find("td").children().eq(5).val();
			 var Rstime=$(this1).parent().parent().find("td").children().eq(6).val();
			 var Retime=$(this1).parent().parent().find("td").children().eq(7).val();
			document.getElementById("study_Room_No_edit").value=Rno;
			document.getElementById("study_Room_Location_edit").value=Rposition;
			document.getElementById("study_Room_Admin_edit").value=Ano;
			document.getElementById("study_Room_Status_edit").value=Rstatus;
			document.getElementById("seat_Num_edit").value=Rseatnum;
			document.getElementById("free_Seat_Num_edit").value=Rfreeseat;
			document.getElementById("test1").value=Rstime;
		    document.getElementById("test2").value=Retime;
		    console.log("xxxxxxxx");
	}
		